package com.itheima.controller;

import com.itheima.entity.Result;
import com.itheima.exception.CustomException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class HandleException {
    @ExceptionHandler({CustomException.class})
    public Result handleCustomException(CustomException e) {
        e.printStackTrace();
        return new Result(false,e.getMessage());
    }

    @ExceptionHandler({Exception.class})
    public Result handleOtherException(Exception e) {
        e.printStackTrace();
        return new Result(false,e.getMessage());
    }
}
